﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SnowDAL;

namespace Snow
{
    public partial class Reply : System.Web.UI.Page
    {
        private TopicDAL _dal = new TopicDAL();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
                DataBindReply();
        }

        private void DataBindReply()
        {
            gvReply.DataSource = _dal.QueryReplyByTid(Request.QueryString["tid"]);
            gvReply.DataBind();
        }

        protected void gvReply_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
        {
            gvReply.EditIndex = -1;
            DataBindReply();
        }

        protected void gvReply_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            string rid = gvReply.DataKeys[e.RowIndex]["rid"].ToString();
            _dal.DeleteReply(rid);
            DataBindReply();
        }

        protected void gvReply_RowEditing(object sender, GridViewEditEventArgs e)
        {
            gvReply.EditIndex = e.NewEditIndex;
            DataBindReply();
        }

        protected void gvReply_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            DataBindReply();
        }

        protected void gvReply_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            gvReply.PageIndex = e.NewPageIndex;
            DataBindReply();
        }
    }
}